package procedure;

/**
 * 测试工序图
 * @author sk.z
 */
public class TestProcess {

    public static Node A() {
        Node n10 = new Node(10, "一", 100, 9000);
        Node n20 = new Node(20, "二", 100, 9000);
        Node n31 = new Node(31, "三1", 100, 9500);
        Node n32 = new Node(32, "三2", 100, 9000);
        Node n41 = new Node(41, "四1", 100, 9500);
        Node n42 = new Node(42, "四2", 100, 9000);
        Node n50 = new Node(50, "五", 100, 8000);
        Node n60 = new Node(60, "六", 100, 8000);
        Node n70 = new Node(70, "七", 100, 9000);

        //设置工序
        n31.setWorkId(new WorkId("w1"));
        n32.setWorkId(new WorkId("w2"));
        n41.setWorkId(new WorkId("w2"));
        n42.setWorkId(new WorkId("w1"));

        //建立关系
        connect(n10,n20);
        connect(n20,n31);
        connect(n20,n32);
        connect(n20,n50);
        connect(n31,n41);
        connect(n32,n42);
        connect(n50,n60);
        connect(n41,n70);
        connect(n42,n70);
        connect(n60,n70);
        return n10;
    }

    public static Node B(){
        Node a = new Node(1, "A", 100, 9000);
        Node b = new Node(2, "B", 100, 9000);
        Node c = new Node(3, "C", 100, 9000);
        Node d = new Node(4, "D", 100, 9000);
        Node e = new Node(5, "E", 100, 9000);
        Node f = new Node(6, "F", 100, 9000);
        Node g = new Node(7, "G", 100, 9000);
        Node h = new Node(8, "H", 100, 9000);
        Node m = new Node(9, "M", 100, 9000);
        Node k = new Node(10, "K", 100, 9000);
        Node w = new Node(11, "W", 100, 9000);

        connect(a,b);
        connect(a,c);
        connect(a,d);
        connect(b,e);
        connect(b,f);
        connect(c,m);
        connect(d,w);
        connect(e,g);
        connect(f,h);
        connect(g,h);
        connect(h,k);
        connect(m,k);
        connect(k,w);
        return a;
    }

    public static Node C(){
        Node a = new Node(1, "A", 100, 9000);
        Node b = new Node(2, "B", 100, 9000);
        Node c = new Node(3, "C", 100, 9000);
        Node d = new Node(4, "D", 100, 9000);
        Node e = new Node(5, "E", 100, 9000);
        Node f = new Node(6, "F", 100, 9000);
        Node g = new Node(7, "G", 100, 9000);
        Node h = new Node(9, "H", 100, 9000);
        Node i = new Node(10, "I", 100, 9000);
        Node j = new Node(11, "J", 100, 9000);
        Node k = new Node(12, "K", 100, 9000);
        connect(a,b);
        connect(a,c);
        connect(b,e);
        connect(b,h);
        connect(c,k);
        connect(e,f);
        connect(f,j);
        connect(f,i);
        connect(h,k);
        connect(j,g);
        connect(i,g);
        connect(g,k);

        return a;
    }

    public static Node D(){
        Node a = new Node(1, "A", 100, 9000);
        Node b = new Node(2, "B", 100, 9000);
        Node c = new Node(3, "C", 100, 9000);
        Node e = new Node(5, "E", 100, 9000);
        Node f = new Node(6, "F", 100, 9000);
        Node g = new Node(7, "G", 100, 9000);
        Node h = new Node(9, "H", 100, 9000);
        Node i = new Node(10, "I", 100, 9000);
        Node j = new Node(11, "J", 100, 9000);
        Node k = new Node(12, "K", 100, 9000);
        Node l = new Node(12, "L", 100, 9000);
        connect(a,c);
        connect(a,b);
        connect(b,e);
        connect(b,h);
        connect(e,f);
        connect(f,j);
        connect(f,i);
        connect(j,g);
        connect(i,g);
        connect(g,l);
        connect(l,k);
        connect(h,l);
        connect(c,k);
        return a;
    }

    private static void connect(Node from, Node to){
        from.addAfter(to);
        to.addPre(from);
    }

}
